package cn.edu.scau.cmi.zhangjunming.interProgramming;

import java.io.IOException;
import java.net.URL;
import java.util.ResourceBundle;

import javafx.fxml.FXML;
import javafx.fxml.FXMLLoader;
import javafx.fxml.Initializable;
import javafx.scene.Parent;
import javafx.scene.Scene;
import javafx.scene.control.Button;
import javafx.scene.control.TextArea;
import javafx.stage.Stage;

public class interProgramController implements Initializable{

	private static Stage stage = null;
	private static Scene scene = null;
	@FXML Button under;
	@FXML Button gradu;
	@FXML Button returnButton;
	@FXML TextArea showArea;
	Student undergraduateStudent;
	Student graduateStudent;
	
	
	public interProgramController() {
		// TODO 自动生成的构造函数存根
		
	}

	@Override
	public void initialize(URL arg0, ResourceBundle arg1) {
		// TODO 自动生成的方法存根
		undergraduateStudent = new UndergraduateStudent();
		graduateStudent =  new GraduateStudent();
	}
	
	static void createScene() {
		if(scene ==null) {
			try {
				URL url = new interProgramController().getClass().getResource("interProgram.fxml");
				Parent root = FXMLLoader.load(url);
				scene = new Scene(root);
			}catch(IOException e) {
				e.printStackTrace();
			}
		}
	}
	
	public static Stage getStage() {
		return stage;
	}
	
	public static void setStage(Stage stage) {
		interProgramController.stage = stage;
	}
	
	@FXML private void u_stu() {
		showArea.clear();
		showArea.appendText(undergraduateStudent.Learning());
	}
	
	@FXML private void g_stu() {
		showArea.clear();
		showArea.appendText(graduateStudent.Learning());
	}
	
	@FXML private void returnBack() {
		Stage stage = (Stage)returnButton.getScene().getWindow();
		stage.close();
	}

}
